package com.lemon.funplus.cheanh;

import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class BrushSizeSeekbarListener implements OnSeekBarChangeListener {
	BrushSettingDialog frag;
	EraserSettingDialog eraser;
	int maxRadius;
	boolean opacity;

	public BrushSizeSeekbarListener(BrushSettingDialog frag, boolean opacity) {
		this.frag = frag;
		this.opacity = opacity;
	}

	public BrushSizeSeekbarListener(EraserSettingDialog eraser) {
		this.eraser = eraser;
	}

	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onProgressChanged(SeekBar seekBar, int progress,
			boolean fromUser) {
		this.maxRadius = ((BrushSettingDialog) frag).brushIndicator.maxRadius;
		if (maxRadius > 0) {
			if (opacity == true) {
				BrushSettingDialog frag = ((BrushSettingDialog) this.frag);
				frag.setPaintAlpha(progress);
			} else {
				BrushSettingDialog frag = ((BrushSettingDialog) this.frag);
				frag.setBrushRadius((int) ((progress / 100.0f) * (maxRadius - 1)) + 1);
				frag.updateRadius();
			}
		}
	}
}
